import axios from 'axios'

// 创建带基础配置的axios实例
const service = axios.create({
    baseURL: import.meta.env.VITE_API_BASE_URL || '/api',
    timeout: 5000
})

// 获取员工列表
export const getEmployeeList = (params) => {
    return axios.get('/api/employees', { params })
}

// 添加员工
export const addEmployee = (data) => {
    return axios.post('/api/employees', data)
}

// 获取员工详情
export const getEmployeeDetail = (id) => {
    return service.get(`/employees/${id}`)
}

// 更新员工信息
export const updateEmployee = (data) => {
    if (!data.id) {
        return Promise.reject(new Error('缺少员工ID'))
    }
    return service.put(`/employees/${data.id}`, data)
}